<?php
namespace Home\Controller;
use Think\Controller;
class MapController extends BaseController {
    public function index(){
        $this->display();
    }
    public function loudongData(){
        $data = M('loudong')->select();
        show(1,'',$data);
    }
    public function xiaoquData(){
        $data = M('xiaoqu')->find(I('post.xiaoquid'));
        show(1,'',$data);
    }
    public function danyuanfangData(){
        $loudongid = I('post.id');  //楼栋id

        $xiaoquid = I('post.xiaoquid');  //楼栋id
        $data = M()->query("SELECT b.*, a.`name`  FROM zn_danyuan as a RIGHT JOIN zn_house as b ON a.id=b.danyuanid WHERE a.loudong_id=$loudongid and a.xiaoqu_id=$xiaoquid");
        show(1,'',$data);
    }

    //通过房id获取房屋的信息
    public function getfangData(){
        $data = M('house')->find(I('post.fangid'));
        show(1,'',$data);
    }

    //改变门禁状态
    public function menjinStatus(){
        $data = array();
        $data['fang_id'] = I('post.fangid');
        $data['menjin_status'] = I('post.menjin_status');

        $res = M('house')->save($data);
        if($res===false){
            show(0,'状态更改失败');
        }else{
            show(1,'状态更改成功');
        }
    }

    //通过房id获取开关门状态
    public function getjiluData(){
        $data = M('jilu')->where(array('house_id'=>I('post.fangid')))->find();
        show(1,'',$data);
    }
//    public function _before_ceshi(){
//        echo I('get.id');
//        echo '前置方法';
//    }
    public function ceshi($id){
        $model = M('Admin');
//        dump($model);
        var_dump(date("Y-m-d H:i:s", strtotime("2018/9/6 16:55:33")));
        dump(strtotime('now'));





//        $arr = array('id'=>1,'name'=>'zhangsan','age'=>23);
//        $arr_value = array_values($arr);
//        dump($arr_value);
//        if(in_array('1',$arr_value)){
//            echo "在数组中";
//        }
//        $arg = 'LIGUIGONG';
//        echo strtolower($arg);
    }
}